package day4;

import java.util.Scanner;

public class Vehicle {
//	属性：速度(speed)，体积(size)等等
//	方法：移动(move())，加速speedUp(),减速speedDown()
	private int speed;
	private int size;
	private Scanner scanner;
	public Vehicle() {
		scanner = new Scanner(System.in);
		System.out.println("请输入速度：");
		this.speed = scanner.nextInt() ;
		System.out.println("请输入体积：");
		this.size = scanner.nextInt();
	}
	public int getSpeed() {
		return speed;
	}
	public void setSpeed(int speed) {
		this.speed = speed;
	}
	public int getSize() {
		return size;
	}
	public void setSize(int size) {
		this.size = size;
	}
	
	
	public void move() {
		
	}
	public void speedUp() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入要增加的速度：");
		int i = scanner.nextInt();
		speed = speed + i;
		System.out.println("增加"+ i +"速度：" + speed);
		 
	}
	public void speedDown() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入要减少的速度：");
		int i = scanner.nextInt();
		speed = speed - i;
		if (speed < 0) {
			speed = 0;
		}
		System.out.println("减少" + i + "速度：" + speed);
	}
}
